package com.aidex.system.service.impl;

import java.util.List;

import com.aidex.risk.domain.*;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.domain.entity.SysDept;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.framework.cache.DeptUtils;
import com.aidex.framework.cache.UserUtils;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aidex.system.mapper.WaybillDetailMapper;
import com.aidex.system.domain.WaybillDetail;
import com.aidex.system.service.WaybillDetailService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 运单明细Service业务层处理
 * @author wll
 * @email wll
 * @date 2021-10-04
 */
@Service
@Transactional(readOnly = false)
public class WaybillDetailServiceImpl extends BaseServiceImpl<WaybillDetailMapper, WaybillDetail> implements WaybillDetailService
{
    private static final Logger log = LoggerFactory.getLogger(WaybillDetailServiceImpl.class);

    /**
     * 获取单条数据
     * @param waybillDetail 运单明细
     * @return 运单明细
     */
    @Override
    public WaybillDetail get(WaybillDetail waybillDetail)
    {
        WaybillDetail dto = super.get(waybillDetail);
        return dto;
    }

    /**
     * 获取单条数据
     * @param id 运单明细id
     * @return 运单明细
     */
    @Override
    public WaybillDetail get(String id)
    {
        WaybillDetail dto = super.get(id);
        return dto;
    }


    /**
     * 查询运单明细列表
     * @param waybillDetail 运单明细
     * @return 运单明细
     */
    @Override
    public List<WaybillDetail> findList(WaybillDetail waybillDetail)
    {
        return super.findList(waybillDetail);
    }

    /**
     * 分页查询运单明细列表
     * @param waybillDetail 运单明细
     * @return 运单明细
     */
    @Override
    public PageInfo<WaybillDetail> findPage(WaybillDetail waybillDetail)
    {
        return super.findPage(waybillDetail);
    }

    /**
     * 保存运单明细
     * @param waybillDetail
     * @return 结果
     */
    @Override
    public boolean save(WaybillDetail waybillDetail)
    {
        return super.save(waybillDetail);
    }


    /**
     * 删除运单明细信息
     * @param waybillDetail
     * @return 结果
     */
    @Override
    public boolean remove(WaybillDetail waybillDetail)
    {
        return super.remove(waybillDetail);
    }

    /**
     * 批量删除运单明细
     * @param ids 需要删除的运单明细ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteWaybillDetailByIds(String[] ids)
    {
        return mapper.deleteWaybillDetailByIds(ids);
    }
    @Transactional(readOnly = false)
    @Override
    public int deleteWaybillDetailByWaybillId(String waybillId)
    {
        return mapper.deleteWaybillDetailByWaybillId(waybillId);
    }

    @Override
    public List<WaybillDetail> getListByWaybillId(String waybillId) {
        WaybillDetail detail = new WaybillDetail();
        detail.setWaybillId(waybillId);
        return mapper.findList(detail);
    }

    @Override
    public List<agentCreditResponseItem> queryAgentCredit(agentCreditRequest info) {
        //SELECT agent_level,date_format(b.create_time,'%Y-%m-%d') create_time,count(*) FROM `waybill` a join v_international_record b on a.waybill_no=b.mwbNo where flight_date ,risk_rating, agent_code group by agent_level,date_format(b.create_time,'%Y-%m-%d')
        if(info.querytype!=null && info.querytype.equals("月")){
            return mapper.queryAgentCreditMonth(info);
        }else if(info.querytype!=null && info.querytype.equals("日")){
            return mapper.queryAgentCredit(info);
        }else{
            return mapper.queryAgentCreditHour(info);
        }

    }

    @Override
    public List<securityCheckResponseItem> querySecurityCheck(securityCheckRequest info) {
        //SELECT risk_rating,checkpoint,count(*) FROM `waybill` a join v_international_record b on a.waybill_no=b.mwbNo where flight_date ,risk_rating, agent_code  group by risk_rating,checkpoint
        return mapper.querySecurityCheck(info);
    }

    @Override
    public List<airlineCargoResponseItem> queryAirlineCargo(airlineCargoRequest info) {
        //SELECT risk_rating,count(*),flight_no FROM `waybill` where flight_date ,destination agent_code
        return mapper.queryAirlineCargo(info);
    }
    @Override
    public List<airlineCargoResponseItem> queryAirlinePieceCargo(airlineCargoRequest info) {
        //SELECT risk_rating,count(*),flight_no FROM `waybill` where flight_date ,destination agent_code
        return mapper.queryAirlinePieceCargo(info);
    }
    @Override
    public List<String> queryAirline() {
        return mapper.queryAirline();
    }

}
